package com.audaque.springboot.foshanupload.web.raspcloud.req.ext;

import com.audaque.springboot.foshanupload.core.model.qo.page.Page;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;

/**
 * <p>
 * 用户
 * </p>
 *
 * @author chinaben
 * @since 2025-07-02
 */
@Data
@Getter
@Setter
@Schema(name = "UserCreateReq", description = "用户")
public class UserUpdateReq extends Page implements Serializable {

    private static final long serialVersionUID = 1L;


    @Schema(description = "id")
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;


    @NotBlank(message = "用户名不能为空")
    @Pattern(regexp = "^[a-zA-Z0-9_]{4,20}$", message = "用户名只能包含字母、数字、下划线，长度4-20位")
    @Schema(description = "用户账号")
    private String username;

    @NotBlank(message = "用户昵称不能为空")
    @Schema(description = "用户昵称")
    private String nickName;

    @Pattern(regexp = "^[a-zA-Z0-9]+@[a-zA-Z0-9]+\\.com$", message = "请输入正确的邮箱，格式如abc123@xxx.com")
    // 基于Spring Validation生成入参限制:大小写字母数组+@+.com结尾
    @Schema(description = "用户邮箱")
    private String email;

    // 基于Spring Validation生成入参限制
    @Pattern(regexp = "^1[3-9]\\d{9}$", message = "请输入正确的手机号码")
    @Schema(description = "手机号码")
    private String phone;

    @Schema(description = "用户性别（0男 1女）")
    private Boolean sex;

    @Schema(description = "头像地址")
    private String avatar;

    @NotBlank(message = "密码不能为空")
    @Pattern(regexp = "^(?:(?=.*[A-Z])(?=.*[a-z])(?=.*\\d)|(?=.*[A-Z])(?=.*[a-z])(?=.*\\W)|(?=.*[A-Z])(?=.*\\d)(?=.*\\W)|(?=.*[a-z])(?=.*\\d)(?=.*\\W)).{8,20}$", message = "密码必须为8-20位，且包含大写字母、小写字母、数字、特殊字符三种中的至少三种")
    @Schema(description = "密码")
    private String password;

    @Schema(description = "备注")
    private String remark;

    @NotNull(message = "是否启用不能为空")
    @Schema(description = "是否启用（0禁用 1启用）")
    private Boolean enableYn;

    @NotNull(message = "角色不能为空")
    @Schema(description = "角色id")
    private Long roleId;

}
